
package fnord.jovian.tango;

import java.awt.*;
import java.util.Vector;

import fnord.jovian.*;
import fnord.jovian.tango.TheCard.TheCardInOut;
import fnord.jovian.tango.TheCard.TheCardOrientation;

public class TheDeck implements TheObject {

	private Vector<TheCard> _cards;
	private int deckSize = 3;

	public TheDeck(TheBoard board, boolean mini) {
		_cards = new Vector<TheCard>();
		if (mini) {
			deckSize = 2;
			TheCard deckCard = new TheGroupCard("FNORD Deck",
					TheCardOrientation.WEST,
					new TheCardInOut[] {TheCardInOut.BLANK,TheCardInOut.BLANK,TheCardInOut.BLANK,TheCardInOut.BLANK},
					board);
			for (int i = 0; i < deckSize; i++) {
				_cards.add(deckCard.getMiniCard());
				_cards.get(i).setColor(new Color(20,20,20));
			}
		}
		else {
			for (int i = 0; i < deckSize; i++) {
				_cards.add(new TheGroupCard("FNORD Deck",
						TheCardOrientation.WEST,
						new TheCardInOut[] {TheCardInOut.BLANK,TheCardInOut.BLANK,TheCardInOut.BLANK,TheCardInOut.BLANK},
						board));
				_cards.get(i).setColor(new Color(20,20,20));
			}
		}
		_cards.get(0).setColor(new Color(60,60,60));
	}

	public void paint(Graphics2D g) {
		for (int i = deckSize-1; i >= 0; i--) {
			_cards.get(i).paint(g);
		}
	}

	public boolean contains(Point p) {
		return _cards.get(0).contains(p);
	}

	@Override
	public boolean containsClick(Point p) {
		return _cards.get(0).containsClick(p);
	}

	@Override
	public boolean containsDrag(Point p) {
		return _cards.get(0).containsDrag(p);
	}

	@Override
	public boolean containsUp(Point p) {
		return _cards.get(0).containsUp(p);
	}

	@Override
	public double getX() {
		return _cards.get(0).getX();
	}

	@Override
	public double getY() {
		return _cards.get(0).getY();
	}

	@Override
	public double getCenterX() {
		return _cards.get(0).getCenterX();
	}

	@Override
	public double getCenterY() {
		return _cards.get(0).getCenterY();
	}

	@Override
	public void setLocation(double x, double y) {
		for (int i = 0; i < deckSize; i++) {
			_cards.get(i).setLocation(x+i,y+i);
		}
	}

	@Override
	public double getWidth() {
		return _cards.get(0).getWidth();
	}

	@Override
	public double getHeight() {
		return _cards.get(0).getHeight();
	}

	@Override
	public void setSize(double w, double h) {
		for (int i = 0; i < deckSize; i++) {
			_cards.get(i).setSize(w,h);
		}
	}

}
